package com.example.ruanshe3.service;

import com.example.ruanshe3.mapper.DataMapper;
import com.example.ruanshe3.model.*;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class DataService {

    @Autowired(required = false)
    private DataMapper dataMapper;

    //增
    //用户
    public String insertuser(int userid, String username, String password, String phone) {
        dataMapper.insertuser(userid, username, password, phone);
        return "succeed";
    }
    //评论
    public String insertreview(int reviewid, int type, int objectid, int id, String content, String reviewtime) {
        dataMapper.insertreview(reviewid, type, objectid, id, content, reviewtime);
        return "succeed";
    }
    //上传
    public String insertupload(int uploadid,int type, int objectid, String uploadtime) {
        dataMapper.insertupload(uploadid, type, objectid, uploadtime);
        return "succeed";
    }
    //点赞
    public String insertlikes(int likesid,int type, int objectid) {
        dataMapper.insertlikes(likesid, type, objectid);
        return "succeed";
    }
    //收藏
    public String insertcollect(int collectid,int type, int objectid) {
        dataMapper.insertcollect(collectid, type, objectid);
        return "succeed";
    }
    //个体
    public String insertobject(int type, int objectid, String name, String image, String cotent, String detail) {
        dataMapper.insertobject(type, objectid, name, image, cotent, detail);
        return "succeed";
    }

    //删
    public void deletereview(int id) {
        dataMapper.deletereview(id);
    }
    public void deleteuser(int userid) {
        dataMapper.deleteuser(userid);
    }
    public void deletelikes(likes data) {
        dataMapper.deletelikes(data);
    }
    public void deleteupload(upload data) {
        dataMapper.deleteupload(data);
    }
    public void deletecollect(collect data) {
        dataMapper.deletecollect(data);
    }
    public void deleteobject(int type,int objectid) {
        dataMapper.deleteobject(type,objectid);
    }
    //改
    

    //查
    //全部个体所有信息
    public List<object> findObject(int type) {
        return dataMapper.findObject(type);
    }
    //按关键字查询个体信息
    public List<object> findObjectByKey(String key,int type) {
        return dataMapper.findObjectByKey(key,type);
    }
   //查询后按日期排序的所有个体
    public List<object> findObjectByKeySortTimeAsc(String key,int type) {
        return dataMapper.findObjectByKeySortTimeAsc(key,type);
    }
    public List<object> findObjectByKeySortTimeDesc(String key,int type) {
        return dataMapper.findObjectByKeySortTimeDesc(key,type);
    }
    //查询后按收藏数排序的所有个体
    public List<object> findObjectByKeySortCollectAsc(String key,int type) {
        return dataMapper.findObjectByKeySortCollectAsc(key,type);
    }
    public List<object> findObjectByKeySortCollectDesc(String key,int type) {
        return dataMapper.findObjectByKeySortCollectDesc(key,type);
    }
    //查询后按点赞数排序的所有个体
    public List<object> findObjectByKeySortLikesAsc(String key,int type) {
        return dataMapper.findObjectByKeySortLikesAsc(key,type);
    }
    public List<object> findObjectByKeySortLikesDesc(String key,int type) {
        return dataMapper.findObjectByKeySortLikesDesc(key,type);
    }
    //查询后按评论数排序的所有个体
    public List<object> findObjectByKeySortReviewAsc(String key,int type) {
        return dataMapper.findObjectByKeySortReviewAsc(key,type);
    }
    public List<object> findObjectByKeySortReviewDesc(String key,int type) {
        return dataMapper.findObjectByKeySortReviewDesc(key,type);
    }
    //按日期排序的所有个体
    public List<object> findObjectSortTimeAsc(int type) {
        return dataMapper.findObjectSortTimeAsc(type);
    }
    public List<object> findObjectSortTimeDesc(int type) {
        return dataMapper.findObjectSortTimeDesc(type);
    }
    //按收藏数排序的所有个体
    public List<object> findObjectSortCollectAsc(int type) {
        return dataMapper.findObjectSortCollectAsc(type);
    }
    public List<object> findObjectSortCollectDesc(int type) {
        return dataMapper.findObjectSortCollectDesc(type);
    }
    //按点赞数排序的所有个体
    public List<object> findObjectSortLikesAsc(int type) {
        return dataMapper.findObjectSortLikesAsc(type);
    }
    public List<object> findObjectSortLikesDesc(int type) {
        return dataMapper.findObjectSortLikesDesc(type);
    }
    //按评论数排序的所有个体
    public List<object> findObjectSortReviewAsc(int type) {
        return dataMapper.findObjectSortReviewAsc(type);
    }
    public List<object> findObjectSortReviewDesc(int type) {
        return dataMapper.findObjectSortReviewDesc(type);
    }
    //某个个体的所有信息
    public object findOneObject(int type,int objectid) {
        return dataMapper.findOneObject(type,objectid);
    }
    //对某个个体的评论所有信息
    public List<review> findReviewByObject(int type,int objectid) {
        return dataMapper.findReviewByObject(type,objectid);
    }
    //对某个个体的点赞数
    public likes_total findLikes_total(int type,int objectid) {
        return dataMapper.findLikes_total(type,objectid);
    }
    //对某个个体的收藏数
    public collect_total findCollect_total(int type,int objectid) {
        return dataMapper.findCollect_total(type,objectid);
    }
    //对某个个体的评论数
    public review_total findReview_total(int type,int objectid) {
        return dataMapper.findReview_total(type,objectid);
    }
    //某个用户收藏的所有个体
    public List<object> findObjectByCollect(int collectid,int type,String key) {
        return dataMapper.findObjectByCollect(collectid,type,key);
    }
    //按日期排序某个用户收藏的所有个体
    public List<object> findObjectByCollectSortTimeAsc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortTimeAsc(collectid,type,key);
    }
    public List<object> findObjectByCollectSortTimeDesc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortTimeDesc(collectid,type,key);
    }
    //按收藏排序某个用户收藏的所有个体
    public List<object> findObjectByCollectSortCollectAsc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortCollectAsc(collectid,type,key);
    }
    public List<object> findObjectByCollectSortCollectDesc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortCollectDesc(collectid,type,key);
    }
    //按点赞数排序某个用户收藏的所有个体
    public List<object> findObjectByCollectSortLikesAsc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortLikesAsc(collectid,type,key);
    }
    public List<object> findObjectByCollectSortLikesDesc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortLikesDesc(collectid,type,key);
    }
    //按评论数排序的所有个体
    public List<object> findObjectByCollectSortReviewAsc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortReviewAsc(collectid,type,key);
    }
    public List<object> findObjectByCollectSortReviewDesc(int collectid,int type,String key) {
        return dataMapper.findObjectByCollectSortReviewDesc(collectid,type,key);
    }
    //用户的所有信息
    public user findUser(int userid) {
        return dataMapper.findUser(userid);
    }
    public user findUserByName(String username) {
        return dataMapper.findUserByName(username);
    }
    //某用户是否点赞过某个体
    public likes findIfLikes(likes data) {
        return dataMapper.findIfLikes(data);
    }
    //某用户是否收藏过某个体
    public collect findIfCollect(collect data) {
        return dataMapper.findIfCollect(data);
    }
    //查询食品或笔记个体数
    public total findObject_total(int type) {
        return dataMapper.findObject_total(type);
    }
    //查询用户数
    public total findUser_total() {
        return dataMapper.findUser_total();
    }
    //查询某次上传信息
    public upload findUpload(int type,int objectid){
        return dataMapper.findUpload(type, objectid);
    }
}